#ifndef DRUNKSCENEMODEL_H
#define DRUNKSCENEMODEL_H

#include <QObject>
#include <QLinkedList>
#include "noise.h"
#include "sceneobject.h"

class DrunkSceneModel :public QObject{
    Q_OBJECT
public:
    DrunkSceneModel(int stateUpdateIntervals,float mapWidth,float mapHeight,Noise *noise,float movementSpeedInMps=0.5,int fallingDownPenalty=5000,QObject *parent=0);
    ~DrunkSceneModel();

    QLinkedList<SceneObject*> getObjectsAtDistance(double distance=20);
    float getYPosition();
    float getXPosition();
    float getTilt();
    float getInputAcc();
    float getOpponentsPosition();
    float getMapLength();
    float getMapWidth();

    bool getIsStanding();

    int getTotalTimeToFinish(){return totalMsToComplete;}
private:
    float tilt;
    float inputAcc;
    float movementSpeed;
    float yPosition;
    float xPosition;
    float mapLength;
    float mapWidth;
    bool isStanding;

    int updateStateIntervals;
    int fallingDownPenalty;
    int timeToStandInMilliseconds;
    float opponentPos;
    float tiltFactor;//difficulty

    float gravityEffect;
    float randomness;
    float speedBoost;

    Noise *noise;

    int totalMsToComplete;

    QTime *startingTime;
    QLinkedList<SceneObject* > inactiveObjects;
    QLinkedList<SceneObject* > activeObjects;

    //updateState functionality
    void moveHeadAndXPosition();
    void collisionDetection();
    void removeEffects();
    void interactWithObject(SceneObject* obj,bool activate);
signals:
    void standCountdown(int millisecondsToStand);
    void reachedEndOfMap(int);
    void playerPosition(float y);
public slots:
    void updateState();
    void setNavigationDifficulty(float navigationDifficulty);
    void putObject(SceneObject* object);
    void setInput(float acc);
    void setOpponentPosition(float yPos);
};
#endif // DRUNKSCENEMODEL_H
